<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8"> 
  <meta name="”renderer”" content="”webkit”"> 
  <meta http-equiv="”X-UA-Compatible”" content="”IE=Edge,chrome=1″"> 
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> 
  <title>乐直播-硬件设备</title> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/staticRep/layui/css/layui.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/portal/css/le-main24.css?cdnv=0.16"> 
  <link rel="stylesheet" href="http://cdn.lezhibo.com/static/libs/font-awesome/css/font-awesome.min.css?cdnv=0.16"> 
  <style type="text/css">
    .le-hardware-laythis-icon{display: none;}
        </style> 
  <script src="http://cdn.lezhibo.com/static/portal/js/fastclick.js?cdnv=0.16"></script> 
 </head> 
 <body> 
  <div class="le-main"> 
<%@include file="portal_navi.jsp" %>
  </div> 
  <div class="le-head-content"> 
   <ul class="le-hardware-content"> 
    <!-- <li class="le-add-hardware">
            <a class="le-hardware-link" layer-func="reloadPage()" href="javascript:void(0)" layer-href="/portal/device/_add">
                <p><i class="fa fa-plus-circle fa-4x" aria-hidden="true"></i></p>
                <h3>新建硬件</h3>
            </a>
        </li>--> 
    <li class="le-hardware-laythis"> 
     <div class="le-hardware-img"> 
      <img src="http://cdn.lezhibo.com/attachment/20170816/b9b5802b704e45929c54824f14fcb837.png"> 
     </div> 
     <div class="le-hardware-describe"> 
      <h2>虚拟设备2222222</h2> 
      <p></p> 
      <p>使用中...</p> 
      <p class="le-set-btn"> <button class="layui-btn layui-btn-small" layer-href="/portal/device/doEdit?device=f964ae51e5004eb289ad48028dddc9e5">设置</button> <button class="layui-btn layui-btn-small" confirm-href="${ctx }/portal/activity/unBindDevice.vo?id=98d28db0b1144b44a86b60db5c1da9b0&amp;device=f964ae51e5004eb289ad48028dddc9e5">释放占用</button> </p> 
     </div> </li> 
   </ul> 
   <div class="le-pages"> 
    <a href="javascript:;" class="previous disabled">上一页</a> 
    <a href="javascript:;" class="active">1</a> 
    <a href="javascript:;" class="next disabled">下一页</a> 
   </div> 
   <div class="clearfix"></div> 
  </div> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticRep/layui/layui.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/staticRep/layui/lay/dest/layui.all.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.min.js?cdnv=0.16"></script> 
  <script type="text/javascript" src="http://cdn.lezhibo.com/static/libs/jquery/jquery.form.min.js?cdnv=0.16"></script> 
  <script>
            var cdnPath="http://cdn.lezhibo.com";//cdn路径
            function fix() {
                var head_height = $('.le-head').outerHeight();
                var window_height = $(window).height();
                var content_height = $('.le-content').outerHeight();
                var sidebar_height = $(".le-sidebar").height();
                var max_height = window_height - head_height;
                if(content_height < sidebar_height){
                    content_height = sidebar_height;
                }

                if(max_height < content_height){
                    max_height = content_height;
                }

                $(".le-content").css('min-height', max_height);
                $(".le-sidebar").css('min-height', max_height);


//                if (content_height < (window_height - head_height)) {
//                    $(".le-content").css('min-height', window_height - head_height);
//                } else {
//                    $(".le-sidebar").css('min-height', content_height);
//                    sidebar_height = content_height;
//                }
//
//                if (sidebar_height < (window_height - head_height)) {
//                    $(".le-sidebar").css('min-height', window_height - head_height);
//                }
            }

            var globalNeedRefreshIndex = "";
            var globalNeedRefreshUrl = "";
            var needRefresh = false;

            function openLayer(url, title, func, isNeedRefreshThisPage) {
                var index = layer.open({
                    type: 2,
                    title: title,
                    shadeClose: true,
                    shade: 0.6,
                    area: ['60%', '80%'],
                    content: url,
                    end: function () {
                        if (needRefresh) {
                            layer.iframeSrc(globalNeedRefreshIndex, globalNeedRefreshUrl);//刷新第几层
                            needRefresh = false;
                        }

                        if (!(typeof(func) == "undefined")) {
                            eval(func);
                        }
                    }
                });

                if (isNeedRefreshThisPage == true) {
                    globalNeedRefreshIndex = index;
                    globalNeedRefreshUrl = url;
                }

            }

            function layerInit() {
                $("[layer-href]").click(function () {
                    if ("" == $(this).attr("layer-need-record")) {
                        openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), true);
                    } else {
                        openLayer($(this).attr("layer-href"), $(this).attr("layer-title"), $(this).attr("layer-func"), false);
                    }
                });

                $("[go-href]").click(function () {
                    var href = $(this).attr("go-href");
                    var newWind = $(this).attr("go-href-new");
                    if (newWind == "true") {
                        window.open(href);
                    } else {
                        window.location.href = href;
                    }
                });


                $("[confirm-href]").click(function () {
                    var href = $(this).attr("confirm-href");
                    if ((typeof(href) == "undefined") || href == null || href == "") {
                        return;
                    }

                    var title = $(this).attr("confirm-title");
                    if ((typeof(title) == "undefined") || title == null || title == "") {
                        title = "您确定执行该操作吗？"
                    }
                    layer.confirm(title, {icon: 9, title: '确定操作 ？'}, function (index) {
                                layer.close(index);
                                $.getJSON(href, function (result) {
                                    if (result.isOk) {
                                        location.reload();
                                    } else {
                                        alert(result.message);
                                    }
                                });
                            },
                            function (index) {
                                layer.close(index);
                            });
                });


            }

            function headerFocus() {
                $("#nav-device").addClass("layui-this");
            }


            function initSidebarUrls() {

                $(".le-sidebar").find(".layui-nav-item").each(function () {
                    var pid = $(this).attr("id");
                    if (typeof(pid) == 'undefined' || null == pid) {
                        return;
                    }

                    var href = $(this).children('a').attr("href");
                    if ((typeof(href) != "undefined") && href.indexOf("?") == -1) {
                        href = href + "?p=" + pid;
                    } else {
                        href = href + "&p=" + pid;
                    }
                    $(this).attr("class", "layui-nav-item");
                    $(this).children('a').attr("href", href);
                });

                $("#").attr("class", "layui-nav-item layui-this");
            }

            var verification = {
                mobiel: function () {
                    $mobile = $("input[validate='mobile']").val();
                    var re = /^1\d{10}$/;
                    if ((typeof($mobile) != "undefined") && !re.test($mobile)) {
                        $("input[validate='mobile']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的手机号</span></p>');
                        return false;
                    }
                },
                email: function () {
                    $email = $("input[validate='email']").val();
                    var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                    if ((typeof($email) != "undefined") && !re.test($email)) {
                        $("input[validate='email']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入正确的邮箱</span></p>');
                        return false;
                    }
                },
                empty: function () {
                    var $input = $("input[validate='empty']");
                    for (var i = 0; i < $input.length; i++) {
                        if ($input.eq(i).val().trim().length == 0) {
                            $("input[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                            return false;
                        }
                    }

                    var $textarea =$("textarea[validate='empty']");
                    for(var i=0;i<$textarea.length;i++){
                        if($textarea.eq(i).val().trim().length==0){
                            $("textarea[validate='empty']").eq(i).after('<p class="le-tips"><span style="color: red;width: 100%">输入不能为空</span></p>');
                            return false;
                        }
                    }
                },

                password: function () {
                    $password = $("input[validate='password']").val();
                    var re = /(.+){6,12}$/;
                    if ((typeof($password) != "undefined") && !re.test($password)) {
                        $("input[validate='password']").after('<p class="le-tips"><span style="color: red;width: 100%">请输入6到12位密码</span></p>');
                        return false;
                    }
                },
                //正整数
                positiveInteger: function () {
                    $positiveInteger = $("input[validate='positiveInteger']");
                    var re=/^[1-9]\d*|0$/;
                    for (var i = 0; i < $positiveInteger.length; i++) {
                        var every=$positiveInteger.eq(i).val().trim();
                        if ((typeof(every) != "undefined") && !re.test(every)) {
                            $("input[validate='positiveInteger']").eq(i).after('<p class="le-tips"><span style="color: red">请输入一个正整数或者0</span></p>');
                            return false;
                        }
                    }
                },
                decimal: function (value) {
                   $decimal = $("input[validate='decimal']");
                    var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                    for (var i = 0; i < $decimal.length; i++) {
                        var every=$decimal.eq(i).val().trim();
                        if ((typeof(every) != "undefined") && !re.test(every)) {
                            $("input[validate='decimal']").eq(i).after('<p class="le-tips"><span style="color: red">值不能小于0</span></p>');
                            return false;
                        }
                    }
                }
            };


            var regularVerify = {
                mobile: function (value) {
                    var re = /^1\d{10}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                email: function (value) {
                    var re = /^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                password: function (value) {
                    var re = /(.+){6,12}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                integer: function (value)     {
//                    var re = /^[1-9]\d*$/;
                    var re = /^\d+$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                decimal: function (value) {
//                    var re = /^[1-9]\d*\.\d*|0\.\d*[1-9]\d*$/;
                    var re = /^[0-9]+\.{0,1}[0-9]{0,2}$/;
                    if ((typeof(value) != "undefined") && !re.test(value)) {
                        return false;
                    }
                },
                empty: function (value) {
                    if (value.trim().length == 0) {
                        return false;
                    }
                }
            }


            function leSubmit() {
                $("[le-submit]").click(function () {
                    var $form = $(this).parents("form");
                    var sfunc = $form.attr("success-func");
                    var bfunc = $form.attr("before-func");
                    $form.ajaxSubmit({
                        type: "post",
                        dataType: "json",
                        beforeSend: function () {
                            if(bfunc != null){
                                if(false == eval(bfunc)){
                                    return false;
                                }
                            }
                            $(".le-tips").remove();
                            if (false == verification.empty()) {
                                return false;
                            }
                            if (false == verification.mobiel()) {
                                return false;
                            }
                            if (false == verification.email()) {
                                return false;
                            }
                            if (false == verification.password()) {
                                return false;
                            }
                        },
                        success: function (result) {
                            if (sfunc != null) {
                                eval(sfunc);
                                return;
                            }

                            if (result.isOk) {
                                parent.isUpdateData = true;
                                parent.layer.closeAll();
                            } else {
                                alert(result.message);
                            }
                        },
                        error: function () {
                            alert("信息提交错误");
                        }
                    });
                })
            }

            //对日期选择范围的控制
            //对id为begin-date和end-date的日期选择控件进行控制
            function verifyDate() {
                layui.use('laydate', function () {
                    var laydate = layui.laydate;
                    var start = {
                        min: '2006-01-01 00:00:00',
                        max: '2099-06-16 23:59:59',
                        istoday: false,
                        choose: function (datas) {
                            end.min = datas;    //开始日选好后， 重置结束日的最小日期
                            end.start = datas;  //将结束日的初始值设定为开始日
                        }
                    };

                    var end = {
                        min: '2006-01-01 00:00:00',
                        max: '2099-06-16 23:59:59',
                        istoday: false,
                        choose: function (datas) {
                            start.max = datas;  //结束日选好后, 重置开始日的最大日期
                        }
                    };

                    $('.begin-date').click(function () {
                        start.elem = this;
                        laydate(start);
                    });
                    $('.end-date').click(function () {
                        end.elem = this;
                        laydate(end);
                    });

                });
            }

            fix();
            layerInit();
            headerFocus();
            initSidebarUrls();
            leSubmit();
            verifyDate();


    $(function(){
        $(".le-hardware-laythis").mouseover(function(){
            var $cur = $(".le-hardware-laythis").index($(this));
            $(".le-hardware-laythis-icon").eq($cur).show();
        }).mouseout(function(){
            $(".le-hardware-laythis-icon").hide();
        })
    })

    var isUpdateData = false;
    function reloadPage(){
        if(isUpdateData){
            isUpdateData = false;
            location.reload();
        }
    }


        </script>   
 </body>
</html>